home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 3696 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.5 KB

  1. Path: li.net!usenet
  2. From: bsilvern@li.net (Bob Silvern)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: BORLAND C++ 4.5 wont add .1 and .9
  5. Date: Thu, 25 Jan 1996 17:22:03 GMT
  6. Organization: Harmony Graphics
  7. Message-ID: <4e8e80$jdc@linet02.li.net>
  8. References: <corekinDLG8t4.3C5@netcom.com> <4e5njv$e9v@damon.irf.uni-dortmund.de>
  9. NNTP-Posting-Host: lisuser44.li.net
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. rothert@damon.irf.uni-dortmund.de (Bernd Rothert) wrote:
  13.  
  14. >In article <corekinDLG8t4.3C5@netcom.com>,
  15. >   corekin@netcom.com (david corekin) wrote:
  16. >>I had some problems with floating point numbers as well.  In my
  17.  
  18. >Today I discovered that my BC++ 4.5 doesn't even add 1+1 correctly - try:
  19.  
  20. >#include <stdio.h>
  21. >int one(void) { return 1; }
  22. >int main(void)
  23. >{
  24. >    int zero = 0;
  25. >    int two = (zero == 0) ? one()+1 : zero+1;
  26. >    printf("one() plus 1 is %d\n", two);
  27. >    return 0;
  28. >}
  29.  
  30. >After compiling with "bcc -ml bug21.c" (BC++ version 4.5) the program outputs:
  31. >    one() plus 1 is 1
  32. >which is not exactly what I whould expect...
  33.  
  34. >Bernd
  35.  
  36. If seen some pretty bad Borland bugs, but nothing this bad.  FYI, I tried the
  37. above code on Borland 4.02 and it worked correctly.  I'm curious what the
  38. problem really is.  Is it a problem with the ? operator within the definition
  39. of the variable "two"?  Is it calling the function one() from within the
  40. definition of "two".  Is it a printf bug? None of these seems likely.  Perhaps
  41. you could try simplifying this example to determine the preicise cause of the
  42. error.
  43.  
  44.  
  45.